<template>
  <div class="studentHome">
    <!-- 学生主页面 -->
    <el-container style="height: 100%">
      <!-- 侧边栏 -->
      <el-aside width="200px" style="height: 100%">
        <el-col :span="24" style="height: 100%">
          <h3>欢迎'{{ syudentName }}'学生</h3>
          <!-- @open="handleOpen"
            @close="handleClose" -->
          <el-menu
            :default-active="routePath"
            class="el-menu-vertical-demo"
            :router="true"
            background-color="#545c64"
            text-color="#fff"
            active-text-color="#ffd04b"
          >
            <el-menu-item index="/student/schoolCourse">
              <template slot="title">
                <i class="el-icon-menu"></i>
                <span>学校课程</span>
              </template>
            </el-menu-item>
            <el-menu-item index="/student/schoolTeacher">
              <i class="el-icon-menu"></i>
              <span slot="title">学校老师</span>
            </el-menu-item>
            <el-menu-item index="/student/myCourse">
              <i class="el-icon-menu"></i>
              <span slot="title">我的课程</span>
            </el-menu-item>
            <el-menu-item index="/student/myFollow">
              <i class="el-icon-menu"></i>
              <span slot="title">我的关注</span>
            </el-menu-item>
            <el-menu-item @click="loginOut">
              <i class="el-icon-menu"></i>
              <span slot="title">退出登录</span>
            </el-menu-item>
          </el-menu>
        </el-col>
      </el-aside>
      <el-container>
        <el-main>
          <!-- 主页面 -->
          <el-header>欢迎登录本系统！ </el-header>
          <router-view />
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
import { schools } from "../../../public/schoolData.js";
export default {
  name: "studentHome",
  components: {},
  data() {
    return {
      id: 0,
      routePath: "/student/schoolCourse",
    };
  },
  computed: {
    syudentName: () => {
      return schools.find((data) => {
        return (
          data.id == JSON.parse(sessionStorage.getItem("studentInfo")).studentId
        );
      }).name;
    },
  },
  created() {
    if (this.$route.path == "/student") {
      this.routePath = "/student/schoolCourse";
    } else {
      this.routePath = this.$route.path;
    }
    if (!sessionStorage.getItem("studentInfo")) {
      this.$router.push("/studentLogin");
      this.$message.error("没有权限");
    } else {
      this.id = JSON.parse(sessionStorage.getItem("studentInfo")).studentId;
    }
  },
  methods: {
    loginOut() {
      this.$confirm("退出登录？？？", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          sessionStorage.removeItem("studentInfo");
          this.$router.push("/studentLogin");
        })
        .catch(() => {});
    },
  },
};
</script>
<style scoped>
.studentHome {
  height: 100%;
}
.el-header,
.el-footer {
  background-color: #b3c0d1;
  color: #333;
  text-align: center;
  line-height: 100px;
}
.el-header {
  text-align: center;
  line-height: 60px;
}
.el-aside {
  background-color: #d3dce6;
  color: #333;
  text-align: center;
  line-height: 50px;
}

.el-main {
  background-color: #e9eef3;
  color: #333;
  text-align: center;
  /* line-height: 160px; */
}

body > .el-container {
  margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}
</style>